
// by benny
// 若是需要支持移动端请到unit_convert函数那修改一下

// SCSS variables are information about icon's compiled state, stored under its original file name
//
// .icon-home {
//   width: $icon-home-width;
// }
//
// The large array-like variables contain all information about a single icon
// $icon-home: x y offset_x offset_y width height total_width total_height image_path;
//
// At the bottom of this section, we provide information about the spritesheet itself
// $spritesheet: width height image $spritesheet-sprites;
$adp-name: 'adp';
$adp-x: 0px;
$adp-y: 37px;
$adp-offset-x: 0px;
$adp-offset-y: -37px;
$adp-width: 25px;
$adp-height: 26px;
$adp-total-width: 30px;
$adp-total-height: 251px;
$adp-image: '/images/sprites-common.png';
$adp: (0px, 37px, 0px, -37px, 25px, 26px, 30px, 251px, '/images/sprites-common.png', 'adp', );
$app-set-up-name: 'appSetUp';
$app-set-up-x: 0px;
$app-set-up-y: 83px;
$app-set-up-offset-x: 0px;
$app-set-up-offset-y: -83px;
$app-set-up-width: 25px;
$app-set-up-height: 26px;
$app-set-up-total-width: 30px;
$app-set-up-total-height: 251px;
$app-set-up-image: '/images/sprites-common.png';
$app-set-up: (0px, 83px, 0px, -83px, 25px, 26px, 30px, 251px, '/images/sprites-common.png', 'appSetUp', );
$error-name: 'error';
$error-x: 0px;
$error-y: 0px;
$error-offset-x: 0px;
$error-offset-y: 0px;
$error-width: 17px;
$error-height: 17px;
$error-total-width: 30px;
$error-total-height: 251px;
$error-image: '/images/sprites-common.png';
$error: (0px, 0px, 0px, 0px, 17px, 17px, 30px, 251px, '/images/sprites-common.png', 'error', );
$key-name: 'key';
$key-x: 0px;
$key-y: 129px;
$key-offset-x: 0px;
$key-offset-y: -129px;
$key-width: 26px;
$key-height: 26px;
$key-total-width: 30px;
$key-total-height: 251px;
$key-image: '/images/sprites-common.png';
$key: (0px, 129px, 0px, -129px, 26px, 26px, 30px, 251px, '/images/sprites-common.png', 'key', );
$locker-name: 'locker';
$locker-x: 0px;
$locker-y: 221px;
$locker-offset-x: 0px;
$locker-offset-y: -221px;
$locker-width: 30px;
$locker-height: 30px;
$locker-total-width: 30px;
$locker-total-height: 251px;
$locker-image: '/images/sprites-common.png';
$locker: (0px, 221px, 0px, -221px, 30px, 30px, 30px, 251px, '/images/sprites-common.png', 'locker', );
$vip-name: 'vip';
$vip-x: 0px;
$vip-y: 175px;
$vip-offset-x: 0px;
$vip-offset-y: -175px;
$vip-width: 26px;
$vip-height: 26px;
$vip-total-width: 30px;
$vip-total-height: 251px;
$vip-image: '/images/sprites-common.png';
$vip: (0px, 175px, 0px, -175px, 26px, 26px, 30px, 251px, '/images/sprites-common.png', 'vip', );
$spritesheet-width: 30px;
$spritesheet-height: 251px;
$spritesheet-image: '/images/sprites-common.png';
$spritesheet-sprites: ($adp, $app-set-up, $error, $key, $locker, $vip, );
$spritesheet: (30px, 251px, '/images/sprites-common.png', $spritesheet-sprites, );

// The provided mixins are intended to be used with the array-like variables
//
// .icon-home {
//   @include sprite-width($icon-home);
// }
//
// .icon-email {
//   @include sprite($icon-email);
// }
//
// Example usage in HTML:
//
// `display: block` sprite:
// <div class="icon-home"></div>
//
// To change `display` (e.g. `display: inline-block;`), we suggest using a common CSS class:
//
// // CSS
// .icon {
//   display: inline-block;
// }
//
// // HTML
// <i class="icon icon-home"></i>
// 修改rem大小
$rem: 20px;

@function px2rem($px) {
    @return $px / $rem * 1rem;
}

// 若是不需要转换rem则改一下注释
@function unit_convert($px) {
    @return $px;
    //@return px2rem($px);
}

@mixin sprite-width($sprite) {
  width: unit_convert(nth($sprite, 5));
}

@mixin sprite-height($sprite) {
  height: unit_convert(nth($sprite, 6));
}

@mixin sprite-position($sprite) {
  $sprite-offset-x: unit_convert(nth($sprite, 3));
  $sprite-offset-y: unit_convert(nth($sprite, 4));
  background-position: $sprite-offset-x  $sprite-offset-y;
}

@mixin sprite-image($sprite) {
  $sprite-image: nth($sprite, 9);
  background-image: url(#{$sprite-image});
}

@mixin sprite($sprite) {
  display: inline-block;
  @include sprite-image($sprite);
  @include sprite-position($sprite);
  @include sprite-width($sprite);
  @include sprite-height($sprite);
  background-size: unit_convert($spritesheet-width) unit_convert($spritesheet-height);
}

// The `sprites` mixin generates identical output to the CSS template
//   but can be overridden inside of SCSS
//
// @include sprites($spritesheet-sprites);

@mixin sprites($sprites) {
  @each $sprite in $sprites {
    $sprite-name: nth($sprite, 10);
    .#{$sprite-name} {
      @include sprite($sprite);
    }
  }
}
